package API.String.Practises;

public class AMoveAsB {
    public static void main(String[] args) {
        String st1 = "abcd";
        String st2 = "bcdf";
        String st3 = "bcda";
        if(judge(st1,st2))
            System.out.println("st1经过转化后可以变为st2");
        else
            System.out.println("转化失败");
        if(judge(st1,st3))
            System.out.println("st1经过转化后可以变为st3");
        else
            System.out.println("转化失败");
    }

    public static boolean judge(String str1, String str2) {
        StringBuilder sb1 = new StringBuilder(str1);
        for (int i = 0; i < sb1.length(); i++) {
            sb1.append(sb1.charAt(0));
            sb1.deleteCharAt(0);
            if(str2.equals(sb1.toString()))
                return true;
        }
        return false;
    }
}
